package com.fyy.exception.controller;

import com.fyy.exception.utils.ResultUtil;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author fyy
 * @Description 全局异常测试
 * @Date 2020/6/16 14:25
 */
@RestController
public class ExceptionController {

    private String TEST_USERNAME = "1234";

    @GetMapping(value = "/exception")
    public Object exception(String userName){

        if (null == userName || StringUtils.isEmpty(userName)){
            return ResultUtil.error("账号参数为空!");
        }

        if(!TEST_USERNAME.equals(userName)){
            return ResultUtil.exception("查无此人！");
        }

        List list = new ArrayList();
        list.add("1");
        list.add("2");

        return ResultUtil.success(list);

    }

}
